public class FindKthToTail {
    public Node head;

    public Node FindKthToTail(int k) {//倒数第k个节点。思路：快慢指针，快指针走k-1步，然后快慢指针一起走
        Node fast = this.head;
        Node slow = this.head;
        Node cur = this.head;
        if (k <= 0) {
            return null;
        }
        while (k - 1 > 0) {
            if (fast.next != null) {
                fast = fast.next;
                k--;
            } else {
                System.out.println("没有这个节点");
                return null;
            }
        }
        while (fast.next != null) {
            fast = fast.next;
            slow = slow.next;
        }
        return slow;
    }
}
